import 'package:fish_redux/fish_redux.dart';
import 'action.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebViewComponentState implements Cloneable<WebViewComponentState> {
  String url = '';
  bool isLoad = false;
  bool requestLoad = false;
  bool reRresh = false;
  bool isShopCar = false;
  WebViewController webViewController;
  Function navigationDelegate = (NavigationRequest request, Dispatch dispatch) {
    if (request.url.startsWith('app://')) {
      dispatch(WebViewComponentActionCreator.onHandleUrl(request.url));
      return NavigationDecision.prevent;
    }
    return NavigationDecision.navigate;


  };

  @override
  WebViewComponentState clone() {
    return WebViewComponentState()
      ..url = url
      ..webViewController = webViewController
      ..isLoad = isLoad
      ..requestLoad = requestLoad
        ..reRresh = reRresh;
  }
}

WebViewComponentState initState(Map<String, dynamic> args) {
  return WebViewComponentState();
}
